home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / Implementation / Dialogs / DraftWn.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-13  |  6.3 KB  |  227 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DraftWn.h
  3.  
  4.     Contains:    definition of the DraftWin and DraftInfoRec classes
  5.  
  6.     Owned by:    Eric House
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <0>     6/7/96    eeh        first checked in (moved from ::DocShell:)
  13.  
  14.     To Do:
  15. */
  16.  
  17. #ifndef _DRAFTWN_
  18. #define _DRAFTWN_
  19.  
  20. #ifndef _PLFMDEF_
  21. #include "PlfmDef.h"
  22. #endif
  23.  
  24. #ifndef SOM_ODDraft_xh
  25. #include <Draft.xh>
  26. #endif
  27.  
  28. #ifndef __DIALOGS__
  29. #include <Dialogs.h>
  30. #endif
  31.  
  32. #ifndef __LISTS__
  33. #include <Lists.h>
  34. #endif
  35.  
  36. //==============================================================================
  37. // Constants
  38. //==============================================================================
  39.  
  40. #define kDraftWinNone            0
  41. #define kDraftWinOpen            1
  42. #define    kDraftWinDone            2
  43. #define kDraftWinCreate            3
  44. #define    kDraftWinDelete            4
  45. #define    kDraftWinLowMemAbort    5
  46.  
  47. //==============================================================================
  48. // Scalar Types
  49. //==============================================================================
  50.  
  51. typedef    ODULong    DraftWinAction;
  52. struct DWStringsArray ;
  53.  
  54. enum DraftInfoRecType { kDIRTypeUnknown, kDIRTypeFull, kDIRTypeDummy };
  55.  
  56. //==============================================================================
  57. // Classes defined in this interface
  58. //==============================================================================
  59.  
  60. class DraftWindow;    // very platform dependent
  61. class DraftInfoRec;
  62. class DummyDraftInfoRec;
  63. class FullDraftInfoRec;
  64.  
  65. //==============================================================================
  66. // Classes used by this interface
  67. //==============================================================================
  68.  
  69. class DraftInfoRec 
  70. {
  71. public:
  72.     DraftInfoRec();
  73.     ODVMethod    ~DraftInfoRec();
  74.  
  75.     ODMethod    DraftInfoRecType    GetDIRType()    { return fDIRType; }
  76.  
  77.     // I really don't need First() anymore.
  78. //    ODMethod    DraftInfoRec*    First()     { return fFirst; }
  79.     ODMethod    DraftInfoRec*    Next()         { return fNext; }
  80.     ODMethod    void            SetNext(DraftInfoRec* next)
  81.                 {fNext = next; }
  82.     ODMethod    ODBoolean        ShouldHilite()    { return fShouldHilite; }
  83.     ODMethod    void        SetShouldHilite( ODBoolean should )
  84.                 { fShouldHilite = should ; }
  85.  
  86.     ODMethod    ODIText*    GetComment()    { return fComment; }
  87.     ODMethod    void    SetComment( ODIText* comment)    { fComment = comment; }
  88.  
  89. protected:
  90.     ODMethod    void                SetDIRType(DraftInfoRecType typ)
  91.                 { fDIRType = typ; }
  92.  
  93. private:
  94.     DraftInfoRecType    fDIRType;
  95.     DraftInfoRec*        fNext;
  96. //    DraftInfoRec*        fFirst;
  97.     ODBoolean            fShouldHilite;
  98.     ODIText*            fComment;
  99. };
  100.  
  101. class DummyDraftInfoRec : public DraftInfoRec
  102. {
  103. public:
  104.     DummyDraftInfoRec();
  105. #if ODDebug
  106.     ODVMethod    ~DummyDraftInfoRec();
  107. #endif
  108.     ODMethod    void    SetCommentOwner( FullDraftInfoRec* owner)
  109.             { fCommentOwner = owner; }
  110.     ODMethod    FullDraftInfoRec*    GetCommentOwner()
  111.             { return fCommentOwner; }
  112.     
  113. private:
  114.     FullDraftInfoRec*     fCommentOwner;
  115. };
  116.  
  117. class FullDraftInfoRec : public DraftInfoRec
  118. {
  119. public:
  120.  
  121.     FullDraftInfoRec();
  122.     ODNVMethod    void    InitDraftInfoRec(Environment* ev, ODDraft* draft);
  123.         // note: draft reference is consumed in Init and released in destructor
  124.     ODVMethod    ~FullDraftInfoRec();
  125.     
  126.     ODMethod    ODULong            Number()    { return fDraftNumber; }
  127.     ODMethod    void            SetNumber(ODULong num)
  128.                                             { fDraftNumber = num; }
  129.     ODMethod    ODDraft*        Draft()        { return fDraft;    }
  130.     
  131.     ODMethod    ODIText*    GetNumberString()    {return fDraftNumberString;}
  132.     ODMethod    void        SetNumberString(ODIText* str)
  133.                                                 {fDraftNumberString = str;}
  134.     ODMethod    ODIText*    GetCreated()        {return fSavedString;}
  135.     ODMethod    ODIText*    GetModifiedBy()        {return fModifiedBy;}
  136.  
  137.     ODMethod    ODBoolean    IsExpanded()    { return fCachedComment != kODNULL;}
  138.  
  139.     ODMethod    void        CacheComment()
  140.             { fCachedComment = GetComment(); SetComment(kODNULL); }
  141.     ODMethod    void        UncacheComment()
  142.             { SetComment(fCachedComment); fCachedComment = kODNULL; }
  143. #if ODDebug
  144.     ODMethod    ODIText*    GetCachedComment() { return fCachedComment; }
  145. #endif
  146.  
  147.     ODMethod    ODBoolean    CanExpand()        { return fCanExpand; }
  148.             // The only thing to set this to is true.
  149.     ODMethod    void        SetCanExpand()    { fCanExpand = kODTrue; }
  150.  
  151. private:
  152.     ODDraft*        fDraft;
  153.     ODStorageUnit*    fDraftProperties;
  154.     ODDraftID        fDraftID;
  155.     ODULong            fDraftNumber;
  156.     ODIText*        fDraftNumberString;
  157.     ODULong            fSaved;
  158.     ODIText*        fSavedString;
  159.     ODIText*        fCachedComment;        // null unless expanded
  160.     ODIText*        fModifiedBy;
  161.     ODBoolean        fCanExpand;        // the comment is too long and may be expanded
  162. };
  163.  
  164.  
  165. //==============================================================================
  166. // DraftWindow
  167. //==============================================================================
  168.  
  169. class DraftWindow
  170. {    
  171.   public:
  172.  
  173.     DraftWindow();
  174.     ODNVMethod void     InitDraftWindow(Environment* ev, ODDraft* draft);
  175.     ODVMethod         ~DraftWindow();
  176.  
  177.     ODMethod    DraftWinAction    Drafts(Environment* ev, ODDraft* draft,
  178.             DraftWinAction prevAction, ODBoolean hasWriteAccess);
  179.     ODMethod    FullDraftInfoRec*    InternalizeHistory(Environment*    ev);
  180.     ODMethod    ODDraft*            GetSelectedDraft()    {return fSelectedDraft;}
  181.     
  182.     //ODMethod    void    DraftCreated(Environment* ev, ODDraft* draft);    
  183.     ODMethod    void    DraftSaved(Environment* ev, ODDraft* draft);    
  184.     // used to set the Draft Properties
  185.     // can be used independently of other methods including initialize
  186.  
  187.  
  188.     ODMethod    ODSShort    CountDrafts() ;    
  189.     ODMethod    ListHandle    GetListHandle() {return fListH;}    
  190.     ODMethod    ODBoolean    CreateIsSet() {return fCreateSet;}
  191.     ODMethod    void        SetReadyToClose(ODBoolean readyToClose)
  192.                 { fReadyToClose = readyToClose; }
  193.     ODMethod    ODBoolean    ReadyToClose()
  194.                 { return fReadyToClose; }
  195.     ODMethod    void        GetListRect(Rect* r) {*r = fListRect;}
  196.     ODMethod    void        DeleteSelectedDraft(Environment* ev, ODSession* session);
  197.  
  198.     ODMethod    void        SetHilite( DraftInfoRec* from, short whichRow );
  199.     ODMethod    ODBoolean    ProcessMousedownInList( DialogPtr dialog,
  200.         ListHandle listH, Point mpt );
  201.  
  202.   protected:
  203.       ODMethod    ODBoolean    CreateDraft(Environment* ev);
  204.       ODMethod    ODBoolean    RemoveSelectedDrafts(Environment* ev);
  205.     ODMethod    void    Print();
  206.  
  207.     ODMethod    ListHandle MakeAList( DialogPtr dlg, ODSShort* numLines,
  208.         long refcon );
  209.         
  210. #if ODDebug
  211.     ODMethod    void    CheckConsistency();
  212. #endif
  213.   private:
  214.     ODDraft*            fDraft;
  215.     ODDocument*            fDocument;
  216.     FullDraftInfoRec*    fDraftInfo;
  217.     ODDraft*            fSelectedDraft;
  218.     ODULong                fSelectedDraftNumber;
  219.     ListHandle            fListH;
  220.     Rect                fListRect;
  221.     ODBoolean            fCreateSet;
  222.     FullDraftInfoRec*    fHilitedRow;
  223.     ODBoolean            fReadyToClose;
  224. };
  225.  
  226. #endif    // _DRAFTWIN_
  227.